package sketch.seg.cd;

public class CDFactory {

	public static enum TYPE { StaticKH, DynamicKH };

//	private static CDFactory instance = null;

//	public static CDFactory get() {
//		if (instance == null) {
//			instance = new CDFactory();
//		}
//		return instance;
//	}

	private CDFactory() {

	}

	public static CornerDetector getCD(TYPE type) {
//		if (type == TYPE.StaticKH)
//			return new CDStaticKH();
//		if (type == TYPE.DynamicKH)
//			return new CDDynamicKH();
//		return null;
		String className = "sketch.seg.cd.CD" + type.toString();
		try {
			return (CornerDetector) Class.forName(className).newInstance();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static CornerDetector getCD(String type) {
		return getCD(TYPE.valueOf(type));
	}

	public static TYPE[] getTypes() {
		return TYPE.values();
	}

	public static int getTypeIndex(TYPE type) {
		TYPE[] types = TYPE.values();
		for (int i = 0; i < types.length; i++) {
			if (type == types[i])
				return i;
		}
		return -1;
	}

	public static String[] getTypesString() {
		TYPE[] types = TYPE.values();
		String[] strings = new String[types.length];

		for (int i = 0; i < types.length; i++)
			strings[i] = types[i].toString();

		return strings;
	}

}
